package com.exercise.utils;

import java.lang.reflect.Proxy;

/**
 * @Description: 创建动态代理类
 * @Date: 2019/11/14 18:04
 * @author: xfei
 */
public class CommonProxy {

    /**
     *
     * @param obj 被代理对象
     * @exception: 生成动态代理对象
     * @date: 2019/11/14 18:11
     * @return: java.lang.Object
     */
    public static Object getProxyInstance(Object obj) {
        CommonInvocationHandler handler = new CommonInvocationHandler();
        // 设置被代理对象
        handler.setByProxy(obj);
        return Proxy.newProxyInstance(obj.getClass().getClassLoader(), obj.getClass().getInterfaces(), handler);
    }
}
